GdkWindow *event_window;
GtkCssGadget *gadget;
+ GtkCssGadget *stack_gadget;
GtkCssNode *header_node;
GtkCssNode *tabs_node;
GtkCssNode *arrow_node[4];
gint y);
/*** Gadget Functions ***/
+static void gtk_notebook_measure_stack (GtkCssGadget *gadget,
+ GtkOrientation orientation,
+ gint for_size,
+ gint *minimum,
+ gint *natural,
+ gint *minimum_baseline,
+ gint *natural_baseline,
+ gpointer data);
+static void gtk_notebook_allocate_stack (GtkCssGadget *gadget,
+ const GtkAllocation *allocation,
+ int baseline,
+ GtkAllocation *out_clip,
+ gpointer data);
+static gboolean gtk_notebook_draw_stack (GtkCssGadget *gadget,
+ cairo_t *cr,
+ int x,
+ int y,
+ int width,
+ int height,
+ gpointer data);
static void gtk_notebook_measure_contents (GtkCssGadget *gadget,
GtkOrientation orientation,
gint for_size,
NULL);
gtk_css_gadget_add_class (priv->gadget, GTK_STYLE_CLASS_FRAME);
+ priv->stack_gadget = gtk_css_custom_gadget_new ("stack",
+ GTK_WIDGET (notebook),
+ priv->gadget,
+ NULL,
+ gtk_notebook_measure_stack,
+ gtk_notebook_allocate_stack,
+ gtk_notebook_draw_stack,
+ NULL,
+ NULL);
+
priv->header_node = gtk_css_node_new ();
gtk_css_node_set_name (priv->header_node, I_("header"));
gtk_css_node_add_class (priv->header_node, g_quark_from_static_string (GTK_STYLE_CLASS_TOP));
- gtk_css_node_set_parent (priv->header_node, widget_node);
+ gtk_css_node_insert_before (widget_node, priv->header_node, gtk_css_gadget_get_node (priv->stack_gadget));
gtk_css_node_set_state (priv->header_node, gtk_css_node_get_state (widget_node));
g_signal_connect_object (priv->header_node, "style-changed", G_CALLBACK (node_style_changed_cb), notebook, 0);
g_object_unref (priv->header_node);
}
g_clear_object (&priv->gadget);
+ g_clear_object (&priv->stack_gadget);
remove_switch_tab_timer (notebook);
}
static void
-gtk_notebook_measure_contents (GtkCssGadget *gadget,
- GtkOrientation orientation,
- gint size,
- gint *minimum,
- gint *natural,
- gint *minimum_baseline,
- gint *natural_baseline,
- gpointer unused)
+gtk_notebook_measure_stack (GtkCssGadget *gadget,
+ GtkOrientation orientation,
+ gint size,
+ gint *minimum,
+ gint *natural,
+ gint *minimum_baseline,
+ gint *natural_baseline,
+ gpointer unused)
{
GtkWidget *widget = gtk_css_gadget_get_owner (gadget);
GtkNotebook *notebook = GTK_NOTEBOOK (widget);
GtkNotebookPrivate *priv = notebook->priv;
- GtkNotebookPage *page;
GList *children;
gint child_minimum, child_natural;
- gint vis_pages;
- guint border_width;
- *minimum = 0;
- *natural = 0;
-
- for (children = priv->children, vis_pages = 0; children;
+ for (children = priv->children;
+ children;
children = children->next)
{
- page = children->data;
+ GtkNotebookPage *page = children->data;
if (gtk_widget_get_visible (page->child))
{
- vis_pages++;
_gtk_widget_get_preferred_size_for_size (page->child,
orientation,
size,
*natural = MAX (*natural, child_natural);
}
}
+}
+
+static void
+gtk_notebook_measure_contents (GtkCssGadget *gadget,
+ GtkOrientation orientation,
+ gint size,
+ gint *minimum,
+ gint *natural,
+ gint *minimum_baseline,
+ gint *natural_baseline,
+ gpointer unused)
+{
+ GtkWidget *widget = gtk_css_gadget_get_owner (gadget);
+ GtkNotebook *notebook = GTK_NOTEBOOK (widget);
+ GtkNotebookPrivate *priv = notebook->priv;
+ GtkNotebookPage *page;
+ GList *children;
+ guint border_width;
+
+ gtk_css_gadget_get_preferred_size (priv->stack_gadget,
+ orientation,
+ size,
+ minimum, natural,
+ NULL, NULL);
if (priv->show_tabs)
{
gtk_css_gadget_get_preferred_size (priv->gadget, GTK_ORIENTATION_VERTICAL, -1, minimum, natural, NULL, NULL);
}
+static void
+gtk_notebook_allocate_stack (GtkCssGadget *gadget,
+ const GtkAllocation *allocation,
+ int baseline,
+ GtkAllocation *out_clip,
+ gpointer unused)
+{
+ GtkWidget *widget = gtk_css_gadget_get_owner (gadget);
+ GtkNotebook *notebook = GTK_NOTEBOOK (widget);
+ GtkNotebookPrivate *priv = notebook->priv;
+ GList *children;
+
+ for (children = priv->children;
+ children;
+ children = children->next)
+ {
+ GtkNotebookPage *page = children->data;
+
+ if (gtk_widget_get_visible (page->child))
+ gtk_widget_size_allocate_with_baseline (page->child, (GtkAllocation *) allocation, baseline);
+ }
+
+ if (priv->cur_page)
+ gtk_widget_get_clip (priv->cur_page->child, out_clip);
+}
+
static void
gtk_notebook_allocate_contents (GtkCssGadget *gadget,
const GtkAllocation *allocation,
GtkNotebook *notebook = GTK_NOTEBOOK (widget);
GtkNotebookPrivate *priv = notebook->priv;
GtkPositionType tab_pos = get_effective_tab_pos (notebook);
+ GtkAllocation stack_clip;
gboolean is_rtl;
if (gtk_widget_get_realized (widget))
if (priv->children)
{
gint border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
- GtkNotebookPage *page;
GtkAllocation child_allocation;
- GList *children;
gint i;
child_allocation.x = allocation->x + border_width;
}
}
- children = priv->children;
- while (children)
- {
- page = children->data;
- children = children->next;
-
- if (gtk_widget_get_visible (page->child))
- gtk_widget_size_allocate (page->child, &child_allocation);
- }
+ gtk_css_gadget_allocate (priv->stack_gadget, &child_allocation, -1, &stack_clip);
gtk_notebook_pages_allocate (notebook);
}
gtk_widget_set_clip (widget, &clip);
}
+static gboolean
+gtk_notebook_draw_stack (GtkCssGadget *gadget,
+ cairo_t *cr,
+ int x,
+ int y,
+ int width,
+ int height,
+ gpointer unused)
+{
+ GtkWidget *widget = gtk_css_gadget_get_owner (gadget);
+ GtkNotebook *notebook = GTK_NOTEBOOK (widget);
+ GtkNotebookPrivate *priv = notebook->priv;
+
+ if (priv->cur_page)
+ gtk_container_propagate_draw (GTK_CONTAINER (notebook),
+ priv->cur_page->child,
+ cr);
+
+ return FALSE;
+}
+
static gboolean
gtk_notebook_draw_contents (GtkCssGadget *gadget,
cairo_t *cr,
{
gtk_notebook_paint (widget, cr, x, y, width, height);
- if (priv->cur_page)
- gtk_container_propagate_draw (GTK_CONTAINER (notebook),
- priv->cur_page->child,
- cr);
+ gtk_css_gadget_draw (priv->stack_gadget, cr);
if (priv->show_tabs)
{
/* child visible will be turned on by switch_page below */
gtk_widget_set_child_visible (child, FALSE);
+ gtk_css_node_set_parent (gtk_widget_get_css_node (child), gtk_css_gadget_get_node (priv->stack_gadget));
gtk_widget_set_parent (child, GTK_WIDGET (notebook));
if (tab_label)
{